home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / amos / amoslist-0295.lzh / AMOSLIST / text0192.txt < prev    next >
Encoding:
Text File  |  1995-03-01  |  1.6 KB  |  41 lines

  1.  
  2.  
  3. On Mon, 20 Feb 1995, Daithi Padraig Ocuinn wrote:
  4.  
  5. > I have written a program in Amos which involves a `laser beam`
  6. > being fired from one part of the screen to another.
  7. > To do this I just work out dy and dx ( one of these values
  8. > will be 1) and add them to the original points until the
  9. > destination is reached or it hits something.
  10. > It works fine when run through the editor, yet when compiled...
  11. > does not. Why???  I use real numbers for dx and dy - maybe
  12. > the compiler cannot deal with these or something?
  13. > The beam does not go in the right direction at all.
  14.  
  15. Try not to use anything but integers for games.  Many may disagree, but 
  16. it is simply the only way to go.  Especially since the compiler doesn't 
  17. work well with floats and not always with math functions.  In airTaxi, I 
  18. had a purple sphere magnet that would pull all the cars toward itself.  
  19. This involved some basic vector and magnetism functions, but I used all 
  20. integers to do it.  Simply have an X value that represents 1/100th of a 
  21. pixel, same with Y.  Then set dx or dy to 100 and the other to cos/sin * 100.
  22. Your routine will perform faster too.  If you need more accuracy, use 256 
  23. or more instead of 100.  Just divide by the number to get the real pixel 
  24. position.
  25.  
  26. In my game, I also had to abort at the beginning if SQR(4)<>2.  Why?  
  27. Because the compiler would 20% of the time not include the math libraries 
  28. or something like this.  My purple sphere would not attract anything at 
  29. all - this is how I noticed the problem.
  30.  
  31. Hope this helps - Dave May
  32.  
  33. > Has anyone got a list of inconsistencies in compiler/interpreter
  34. > operation? This is driving me up the wall.
  35. > D.O`Cuinn
  36.  
  37.